package com.zcf.common.yunos.aliyun;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import com.zcf.utils.HttpUtils;

import java.util.HashMap;
import java.util.Map;
/**
 * 阿里物流查询工具
 * @author Administrator
 *
 */
public class FegineApi {
	/**
	 * 
	 * @param code  物流的订单号
	 * @param name 物流的名称
	 * @return
	 */
	public static String Fegine(String code, String name) {

		String host = "http://cexpress.market.alicloudapi.com";
		String path = "/cexpress";
		String method = "GET";
		String appcode = "baf447bf180746df92c0897096a30c4d"; // !!! 替换这里填写你自己的AppCode 请在买家中心查看
		Map<String, String> headers = new HashMap<String, String>();
		headers.put("Authorization", "APPCODE " + appcode); // 格式为:Authorization:APPCODE
		Map<String, String> querys = new HashMap<String, String>();
		querys.put("no", code);// !!! 请求参数
		querys.put("type", name);// !!! 请求参数
		try {
			HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
			// System.out.println(response.toString()); //输出头部
			String tring = EntityUtils.toString(response.getEntity());
			return tring;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
